package tsif.tcluster.netty.codec;

/**
 * netty通讯消息
 * 
 */
public class TClusterNettyMessage {
	protected long sourceServiceId; // 接收的服务Id
	protected long targetServiceId; // 接收的服务Id

	protected short code; // 消息码
	protected byte[] data; // 数据内容(byte[])

	/** 计算消息二进制数据长度 **/
	public int calcLength() {
		return fixedLength() + (data != null ? data.length : 0);
	}

	/** 固定大小 **/
	public int fixedLength() {
		return 8 + 8 + 2 + 2;
	}

	/** 获取消息内容 **/
	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	/** 发送源服务Id **/
	public long getSourceServiceId() {
		return sourceServiceId;
	}

	public void setSourceServiceId(long sourceServiceId) {
		this.sourceServiceId = sourceServiceId;
	}

	/** 接收服务Id **/
	public long getTargetServiceId() {
		return targetServiceId;
	}

	public void setTargetServiceId(long targetServiceId) {
		this.targetServiceId = targetServiceId;
	}

	/** 消息码 **/
	public short getCode() {
		return code;
	}

	public void setCode(short code) {
		this.code = code;
	}
}
